package com.demo.study.reflection;

import java.io.Serializable;

/**
 * @author Baymax
 * @since 2021/10/10
 */
public class Demo02 {
    public static void main(String[] args) {
        DemoA a = new DemoA();
        System.out.println(a.num);
        /**
         * 输出结果：
         * DemoA静态代码块加载
         * DemoA无参构造加载
         * num 的值，跟静态代码块的位置有关
         */
        System.out.println(DemoA.num);
    }
}

class DemoA implements Serializable {
    private static final long serialVersionUID = 177145337602548L;

    static {
        System.out.println("DemoA静态代码块加载");
        num = 300;
    }

    static int num = 100;

    public DemoA() {
        System.out.println("DemoA无参构造加载");
    }
}
